package control;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import model.Curso;
import model.Usuario;
import dao.DAOCurso;
import dao.DAOUsuario;

public class ListarInfoEdicaoTag extends SimpleTagSupport{
	
	private String chave, classe;
	
	public void doTag() throws JspException, IOException 
		{
			if (classe.equals("usuario")){
				DAOUsuario daousuario = new DAOUsuario();
				Usuario u = daousuario.findByLogin(chave);
				getJspContext().setAttribute("nome", u.getNome());
			} else if (classe.equals("curso")){
				DAOCurso daocurso = new DAOCurso();
				Curso c = daocurso.find(chave);
				getJspContext().setAttribute("cargahoraria", c.getCargahoraria());
				getJspContext().setAttribute("descricao", c.getDescricao());				
			}
			getJspBody().invoke(null);
		}
	
	public void setChave (String chave){
		this.chave = chave;
	}
	
	public void setClasse (String classe){
		this.classe = classe;
	}
}